#ifndef CONNECTIONSQLITE_H
#define CONNECTIONSQLITE_H
#include <QSqlDatabase>
#include <QSqlQuery>
static bool createConnection()
{
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("database.db");
    if(!db.open()) return false;
    QSqlQuery query;
    query.exec(QString(
      "create table student (number int primary key,id int,name varchar(40),lesson varchar(40),data varchar(40),type varchar(40))"));
    query.exec(QString("insert into student values(1,1,'张胖胖', '高数', '2019-9-2', '旷课')"));
    query.exec(QString("insert into student values(2,2,'宅本伟', '英语', '2019-9-3',  '迟到')"));
    query.exec(QString("insert into student values(3,3,'一百七', '思修', '2019-9-4', '请假')"));
    query.exec(QString("insert into student values(4,4,'臭臭大佬', '历史', '2019-9-5', '早退')"));
    query.exec(QString("insert into student values(5,5,'吴锡盟', '离散', '2019-9-6',  '旷课')"));
    query.exec(QString("insert into student values(6,6,'帅帅老汤', '离散', '2019-9-6',  '旷课')"));
    return true;
}
#endif // CONNECTIONSQLITE_H
